//
//  WQPictureViewCell.swift
//  sanwuWeibo
//
//  Created by 王先强 on 15/12/12.
//  Copyright © 2015年 王先强. All rights reserved.
//

import UIKit
import SDWebImage
class WQPictureViewCell: UICollectionViewCell{
    var pictureURL: NSURL? {
        didSet{
            imageView.sd_setImageWithURL(pictureURL,
                placeholderImage: nil,                      // 在调用 OC 的框架时，可/必选项不严格
                options: [SDWebImageOptions.RetryFailed,    // SD 超时时长 15s，一旦超时会记入黑名单
                    SDWebImageOptions.RefreshCached])       // 如果 URL 不变，图像变
        }
    }
    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    private func setupUI() {
        contentView.addSubview(imageView)
        
        imageView.snp_makeConstraints { (make) -> Void in
            make.edges.equalTo(self.contentView.snp_edges)
        }
    }
    
   lazy var imageView: UIImageView = {
        let imgView = UIImageView()
        imgView.contentMode = .ScaleAspectFill
        imgView.clipsToBounds = true
        return imgView
    }()
}
